package com.yuanhua.sim.client.socket;

import com.yuanhua.sim.client.decoder.MyDecoder;
import com.yuanhua.sim.client.decoder.MyEncoder;
import com.yuanhua.sim.client.socket.handler.*;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

/**
 * @author YuanHua
 */
public class SuperImChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel channel) throws Exception {

        // 在管道中添加我们自己的接收数据实现方法
        channel.pipeline()
                //向pipeline加入解码器
                .addLast("decoder", new MyDecoder())
                .addLast(new LoginHandler())
                .addLast(new MsgResHandler())
                .addLast(new MsgReqHandler())
                .addLast(new MsgRecHandler())
                .addLast(new OtherEventHandler())
                .addLast(new Pinger())
                //向pipeline加入编码器
                .addLast("encoder", new MyEncoder());
    }

}
